<script setup lang='ts'>
import { ref } from 'vue';
import Child from './14_父子通信中的子组件.vue'
const username = ref("张三") // 声明响应式数据
const age = ref(20) // 声明响应式数据

const changeInfo = () => {
    username.value = "李四"
    age.value++
}
// 父组件定义函数
const receiveFunc = (count: number) => {
    age.value = count
}
const receiveNameFunc = (name: string) => {
    username.value = name
}
const receiveAll = (count: number, name: string) => {
    username.value = name
    age.value = count
}
</script>

<template>
    <div class="parent">
        <h1>当前的父组件</h1>
        <p>姓名：{{ username }}</p>
        <p>年龄:{{ age }}</p>
        <button @click="changeInfo">修改内容</button>
        <Child :name="username" :age="age" :func="receiveFunc" @update-age="receiveFunc" @update-name="receiveNameFunc"
            @update-all="receiveAll">
        </Child>
    </div>

</template>
